{% from 'partials/_defaults.html' import OPEN_GRAPH_IMAGE with context %}
{% from 'partials/_defaults.html' import USE_TWITTER_CARDS with context %}
{% if USE_TWITTER_CARDS %}
    {% from 'partials/_defaults.html' import share_title with context %}
    {% from 'partials/_defaults.html' import share_url with context %}
    {% from 'partials/_defaults.html' import obj with context %}
    {% if TWITTER_USERNAME %}
        <meta property="twitter:site" content="@{{ TWITTER_USERNAME }}">
    {% endif %}
    {% if obj is defined %}
        <meta property="twitter:title"
              content="{{ obj.title|striptags|escape }}">
        <meta property="twitter:url"
              content="{{ SITEURL }}/{{ obj.url }}">
        <meta property="twitter:description"
              content="{{ obj.summary|striptags|escape }}">
        {% if obj.og_image %}
            <meta property="twitter:image"
                  content="{{ SITEURL }}/{{ obj.og_image }}">
            <meta property="twitter:card"
                  content="summary_large_image">
        {% elif OPEN_GRAPH_IMAGE %}
            <meta property="twitter:image"
                  content="{{ SITEURL }}/{{ OPEN_GRAPH_IMAGE }}">
            <meta property="twitter:card" content="summary_large_image">
        {% else %}
            <meta property="twitter:card" content="summary">
        {% endif %}
    {% else %}
        <meta property="twitter:title"
              content="{{ SITENAME|striptags|escape }}">
        <meta property="twitter:url"
              content="{{ SITEURL }}/{{ output_file }}">
        {% if OPEN_GRAPH_IMAGE %}
            <meta property="twitter:image"
                  content="{{ SITEURL }}/{{ OPEN_GRAPH_IMAGE }}">
        {% else %}
            <meta property="twitter:card" content="summary">
        {% endif %}
    {% endif %}
{% endif %}
